package cn.tedu._05interceptor.base.config;

import cn.tedu._05interceptor.base.interceptors.MyInterceptor1;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptionConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //1拦截所有请求
//       registry.addInterceptor(new MyInterceptor1())
//               .addPathPatterns("/v1/**");
        //2拦截指定请求
        registry.addInterceptor(new MyInterceptor1())
               .addPathPatterns("/v1/user/reg","/v1/user/login");
        //3拦截指定请求 用户模块的所有请求
//        registry.addInterceptor(new MyInterceptor1())
//              .addPathPatterns("/v1/user/**");
        //4拦截指定请求用户模块的所有请求除了login
//        registry.addInterceptor(new MyInterceptor1())
//               .addPathPatterns("/v1/user/**")
//                .excludePathPatterns("/v1/user/login");


    }
}
